﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Commerce/Views/Shared/Backend.Master"
    Inherits="System.Web.Mvc.ViewPage<IEnumerable<IProductType>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%: "Product types".Localize()%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h3 class="title">
        <%: "Product types".Localize()%></h3>
    <div class="command">
        <ul class="clearfix">
            <li>
                <%: Html.ActionLink("Create new Product type".Localize(), "create", null, new { @class = "button" })%>
            </li>
        </ul>
    </div>
    <div class="table-container">
        <table>
            <thead>
                <tr>
                    <th class="action">
                        <%: "Enable".Localize() %>
                    </th>
                    <th>
                        <%:"Name".Localize()%>
                    </th>
                    <th class="status-item">
                        <%: "Has package size".Localize()%>
                    </th>
                    <th class="status-item">
                        <%: "Has weight".Localize()%>
                    </th>
                    <th class="action">
                        <%: "Add product".Localize()%>
                    </th>
                    <th class="action">
                        <%: "Edit".Localize()%>
                    </th>
                    <th class="action">
                        <%: "Delete".Localize()%>
                    </th>
                </tr>
            </thead>
            <tbody>
                <% 
                    var index = 0;
                    foreach (var item in Model)
                    {
                %>
                <tr <% if (++index % 2 == 0) {%>class="even" <%} %>>
                    <td class="action">
                        <%: Html.DisplayFor(i=>item.IsEnable) %>
                    </td>
                    <td>
                        <%: item.Name%>
                    </td>
                    <td class="action">
                        <%: Html.DisplayFor(i=>item.HasPackageSize) %>
                    </td>
                    <td class="action">
                        <%: Html.DisplayFor(i=>item.HasWeight) %>
                    </td>
                    <td class="action">
                        <% if (item.IsEnable)
                           { %>
                        <%: Html.ActionLink(" ", "create","Product", new { producttypeid = item.Id }, new { @class="o-icon add"})%>
                        <%} %>
                    </td>
                    <td class="action">
                        <a href="<%= ViewData["edit-action"].ToString().Replace("-1",item.Id.ToString()) %>"
                            class="o-icon edit"></a>
                    </td>
                    <td class="action">
                        <form action='<%= ViewData["delete-action"] %>' method="post" class="delete-form">
                        <%: Html.Hidden("Id",item.Id) %>
                        <a class="o-icon input-icon delete delete-link" message="<%= "Are you sure you want to delete this product type? It will also remove its products.".Localize() %>"
                            href="#"></a>
                        </form>
                    </td>
                </tr>
                <%
                    }
                %>
            </tbody>
        </table>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <%using (var loader = ClientLoader.RegisterInstance())
      {
          loader.Require("producttype.index.js");
      } %>
</asp:Content>
